#include "stdio.h"
#include "math.h"
#define PI 3.14159
main()
{
	int i,j,k;
	int n,p[4],q[10],cycle,demand;
	int a,b;
	float small,cha,out;
	scanf("%d",&n);
	for (k=1;k<=n;k++)
	{
		memset(p,0,sizeof(p));
		memset(q,0,sizeof(q));
		
		for (j=1;j<=3;j++) scanf("%d",&p[j]);
		for (j=1;j<=9;j++) scanf("%d",&q[j]);
		scanf("%d",&cycle);
		scanf("%d",&demand);
		
		small=p[1]*1.0/q[1]*PI*cycle-demand;
		out=p[1]*1.0/q[1]*PI*cycle;
		a=b=1;
		small=abs(small);
		for (i=1;i<=3;i++)
			for (j=1;j<=9;j++)
			{
				cha=p[i]*1.0/q[j]*PI*cycle-demand;	
				cha=abs(cha);
				if (cha<small)
				{
					small=cha;
					out=p[i]*1.0/q[j]*PI*cycle;
					a=p[i];
					b=q[j];
				}
			}
		printf("A gear selection of %d/%d produces a gear size of %.3f.\n",a,b,out);                     if (k!=n) printf("\n");
		
	}

	

}



